/*
 * @Author: weidewei
 * @Date: 2025-05-21 15:31:17
 * @LastEditors: weidewei
 * @LastEditTime: 2025-05-22 10:42:18
 * @Description:
 * @FilePath: \v3\src\stores\index.ts
 */

import { defineStore } from "pinia";
// export const useCounterStore = defineStore("counter", {
//   state: () => ({
//     count: 0,
//     user: { name: "Alice" },
//   }),
//   getters: {
//     doubleCount: (state) => state.count * 2,
//   },
//   actions: {
//     increment() {
//       this.count++; // 直接通过 this 修改状态
//     },
//   },
// });

export const useCounterStore = defineStore('counter', {
  state: () => ({
    count: 0,
    user: { name: "Alice" }
  }),
  getters: {
    doubleCount: (state) => state.count * 2
  },
  actions: {
    increment() {
      this.count++
    }
  },
  persist: {
    storage: localStorage
  }
})
